using System.Collections.Generic;
using System.Text;

namespace zevenseas.Community.Search
{
    public class SelectStatement
    {
        private bool includeDefaultProperties = true;
        private List<string> returnProperties;

        public bool IncludeDefaultProperties
        {
            get { return includeDefaultProperties; }
            set { includeDefaultProperties = value; }
        }

        public List<string> ReturnProperties
        {
            get { return returnProperties; }
            set { returnProperties = value; }
        }

        public SelectStatement()
        {
            GetDefaultProperties();
        }

        private static List<string> GetDefaultProperties()
        {
            List<string> defReturnProperties = new List<string>();
            defReturnProperties.Add("Title");
            defReturnProperties.Add("Rank");
            defReturnProperties.Add("Size");
            defReturnProperties.Add("Description");
            defReturnProperties.Add("Write");
            defReturnProperties.Add("Path");

            return defReturnProperties;
        }

        public override string ToString()
        {
            StringBuilder selectStatement = new StringBuilder();
            selectStatement.Append(@"SELECT ");

            if (includeDefaultProperties)
            {
                foreach (string property in GetDefaultProperties())
                {
                    selectStatement.Append(property);
                    selectStatement.Append(", ");
                }
            }

            foreach (string property in returnProperties)
            {
                selectStatement.Append(property);
                selectStatement.Append(", ");
            }
            selectStatement.Remove(selectStatement.Length - 2, 2);

            return selectStatement.ToString();
        }

    }
}